package com.unohacha.qqj.fzdr.view;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.widget.RelativeLayout;
import android.widget.TextView;


import com.unohacha.qqj.fzdr.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

public class MyDialog extends Dialog {

    Unbinder unbinder;
    @BindView(R.id.text_title)
    TextView textTitle;
    @BindView(R.id.btn_textView)
    TextView btnTextView;
    @BindView(R.id.relative_btn)
    RelativeLayout relativeBtn;

    private Context context;
    private String title;
    private String bottom;

    private MyBottomClickListener bottomClickListener;

    public MyDialog(@NonNull Context context) {
        super(context, R.style.alert_dialog_center);
        this.context = context;
    }

    public void bottomClickListener(MyBottomClickListener bottomClickListener){
        this.bottomClickListener = bottomClickListener;
        show();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.customer_dialog_bank);
        unbinder = ButterKnife.bind(this);
        setCanceledOnTouchOutside(false);
        if (!TextUtils.isEmpty(title)) {
            textTitle.setText(title);
        }

        if (!TextUtils.isEmpty(bottom)) {
            btnTextView.setText(bottom);
        }
    }

    @OnClick(R.id.relative_btn)
    public void onViewClicked() {
        if (bottomClickListener != null) {
            bottomClickListener.bottomClick();
        }
    }

    /**
     * 设置标题
     * @param title
     */
    public void setTextTitle(String title) {
        this.title = title;
    }

    /**
     * 设置按钮内容
     * @param bottom
     */
    public void setTextBottom(String bottom) {
        this.bottom = bottom;
    }

    public interface MyBottomClickListener{
        void bottomClick();
    }
}
